//
//  NSDate(DateFormatting).m
//  ToDoList
//
// This code file is apart of project "iPhone-ToDo-List" 
// (http://code.google.com/p/iphone-todo-list/)
//
// Copyright (c) 2009 Frank Villasenor
//
// Distributed under the terms of the Lesser GNU General Public License.
// A copy of the license should be with these files. If not, you 
// can retrieve a copy from http://www.gnu.org/licenses/lgpl-3.0.txt
// 

#import "NSDate(DateFormatting).h"


@implementation NSDate(DateFormatting)

- (NSString *)getShortDateWithoutTime
{	
	return [self getDateAsStringWithDateFormat:NSDateFormatterShortStyle TimeFormat:NSDateFormatterNoStyle];
}

//
// Not suppose to be public...
- (NSString *)getDateAsStringWithDateFormat:(NSDateFormatterStyle)dateFormatterStyle TimeFormat:(NSDateFormatterStyle)dateFormatterStyleForTime
{
	//
	// Make the style default to the Mac OS 10.4 behavior. This is the
	// prefered behavior for this method but it is not the default behavior.
	//
	[NSDateFormatter setDefaultFormatterBehavior:NSDateFormatterBehavior10_4];
	
	NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
	[dateFormatter setDateStyle:dateFormatterStyle]; 
	[dateFormatter setTimeStyle:dateFormatterStyleForTime]; 
	
	NSString *retValue = [dateFormatter stringFromDate:self];
	[dateFormatter release];
	
	return retValue;
}

@end
